package com.zlc.atonce.huarongdao.algorithme;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

public enum Cell {
    BLANK(CellCoder.TYPE_EMPTY, 'A'),
    SINGLE(CellCoder.DOWN_MASK | CellCoder.UP_MASK | CellCoder.LEFT_MASK | CellCoder.RIGHT_MASK | CellCoder.TYPE_SINGLE, 'B'),
    TWO_LEFT(CellCoder.DOWN_MASK | CellCoder.UP_MASK | CellCoder.LEFT_MASK | CellCoder.TYPE_H_TWO, 'C'),
    TWO_RIGHT(CellCoder.DOWN_MASK | CellCoder.UP_MASK | CellCoder.RIGHT_MASK | CellCoder.TYPE_H_TWO, 'D'),
    TWO_UP(CellCoder.UP_MASK | CellCoder.LEFT_MASK | CellCoder.RIGHT_MASK | CellCoder.TYPE_V_TWO, 'E'),
    TWO_DOWN(CellCoder.DOWN_MASK | CellCoder.LEFT_MASK | CellCoder.RIGHT_MASK | CellCoder.TYPE_V_TWO, 'F'),
    FOUR_LU(CellCoder.UP_MASK | CellCoder.LEFT_MASK | CellCoder.TYPE_FOUR, 'G'),
    FOUR_LD(CellCoder.DOWN_MASK | CellCoder.LEFT_MASK | CellCoder.TYPE_FOUR, 'H'),
    FOUR_RU(CellCoder.UP_MASK | CellCoder.RIGHT_MASK | CellCoder.TYPE_FOUR, 'I'),
    FOUR_RD(CellCoder.DOWN_MASK | CellCoder.RIGHT_MASK | CellCoder.TYPE_FOUR, 'J');

    public static final Map<Integer, Character> int2charMap = Arrays.stream(Cell.values())
            .collect(Collectors.toMap(Cell::getIntCode, Cell::getCharCode));

    public static final Map<Character, Integer> char2intMap = Arrays.stream(Cell.values())
            .collect(Collectors.toMap(Cell::getCharCode, Cell::getIntCode));
    public final int intCode;
    public final char charCode;

    Cell(int intCode, char charCode) {
        this.intCode = intCode;
        this.charCode = charCode;
    }

    public int getIntCode() {
        return intCode;
    }

    public char getCharCode() {
        return charCode;
    }
}
